<?php
class pk_blog extends BaseModel implements Retrievable {

	var $user;
	var $sports;
	var $title;
	var $body;
	
    public function pk_blog($values) {
        parent::__construct($values);
    }

    public function validate() {
        $errors = Array();
		return (count($errors) === 0 ? true : $errors);
    }

    public static function get($id, $primaryKey='id') {
        return parent::get($id, __CLASS__, $primaryKey);
    }
    
    public static function getAll($searchArray=Array(), $sortArray=Array(), $limit=0) {
        return parent::getAll($searchArray, $sortArray, __CLASS__, $limit);
    }
    
    public static function getBlogs($sport) {
    	$blogs = pk_blog::getAll(array("sports"=>"[:custom] like '%|$sport|%'"), array('id', 'DESC'), 20);
    	return $blogs;
    }
    
    public static function getLatestBlog($sport) {
    	$blogs = pk_blog::getBlogs($sport);
    	if(isset($blogs[0])) {
    		return $blogs[0];
    	}
    }
    
}
?>